<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文创产品后台管理系统</title>
    <style>
        /* 基础样式重置 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
        }

        body {
            background-color: #f5f7fa;
            color: #333;
            line-height: 1.6;
            padding: 20px;
        }

        /* 主容器样式 */
        #main {
            max-width: 1000px;
            margin: 0 auto;
            background: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        /* 标题样式 */
        h1 {
            color: #2c3e50;
            text-align: center;
            margin-bottom: 30px;
            padding-bottom: 15px;
            border-bottom: 2px solid #3498db;
        }

        /* 表格样式 */
        #ttbl_product {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }

        #ttbl_product th {
            background-color: #3498db;
            color: white;
            padding: 12px 15px;
            text-align: left;
            font-weight: 500;
        }

        #ttbl_product td {
            padding: 12px 15px;
            border-bottom: 1px solid #e0e0e0;
        }

        #ttbl_product tr:last-child td {
            border-bottom: none;
        }

        #ttbl_product tr:hover {
            background-color: #f8f9fa;
        }

        /* 空库存提示 */
        #ttbl_product tr td[colspan] {
            text-align: center;
            color: #7f8c8d;
            padding: 20px;
        }

        /* 操作按钮样式 */
        a {
            color: #3498db;
            text-decoration: none;
            transition: color 0.3s;
        }

        a:hover {
            color: #2980b9;
            text-decoration: underline;
        }

        /* 删除按钮样式 */
        .delete-btn {
            color: #e74c3c;
            cursor: pointer;
        }

        .delete-btn:hover {
            color: #c0392b;
        }

        /* 列宽定义 */
        .w20 {
            width: 20%;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            #main {
                padding: 15px;
            }

            #ttbl_product {
                display: block;
                overflow-x: auto;
            }
        }

        /* 状态标签 */
        .status {
            display: inline-block;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.8em;
            font-weight: 500;
        }

        .in-stock {
            background-color: #e8f5e9;
            color: #27ae60;
        }

        .low-stock {
            background-color: #fff3e0;
            color: #f39c12;
        }

        .out-of-stock {
            background-color: #ffebee;
            color: #e74c3c;
        }
    </style>
</head>
<body>
<div id="main">
    <h1>文创产品后台管理系统</h1>
    <table id="ttbl_product">
        <tr>
            <th class="w20">名称</th>
            <th class="w20">单价</th>
            <th class="w20">库存</th>
            <th>删除</th>
            <th>详情</th>
        </tr>
        <!-- 如果链表为空 -->
        <tr th:if="${#lists.isEmpty(products)}">
            <td colspan="5">对不起，库存为空！</td>
        </tr>
        <!-- 如果链表不为空，取出数据 -->

        <tr th:unless="${#lists.isEmpty(products)}" th:each="product:${products}">
            <td th:text="${product.pname}"></td>
            <td th:text="${product.price}">5</td>
            <td th:text="${product.stock}">20</td>
            <td><a th:href="@{/productdelete(pid=${product.pid})}" onclick="return confirm('确定要删除这条记录吗？删除后不可恢复！')">删除</a ></td>
            <td> <a th:href="@{/productdetail(pid=${product.pid})}">详情</a ></td>

        </tr>
    </table>
</div>
</body>
</html>